<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input
        v-model="listQuery.user"
        size="small"
        placeholder="请输入用户名"
        clearable
        class="filter-item w-200"
      />
      <el-input
        v-model="listQuery.wid"
        size="small"
        placeholder="帖子WID"
        clearable
        class="filter-item w-200"
      />
      <el-input
        v-model="listQuery.mode"
        size="small"
        placeholder="操作模块"
        clearable
        class="filter-item w-200"
      />

      <el-button-group class="filter-item">
        <el-button
          size="small"
          type="primary"
          icon="el-icon-search"
          @click="search"
        >
          搜索
        </el-button>
        <el-button
          size="small"
          type="primary"
          icon="el-icon-refresh"
          @click="refresh"
        >
          重置
        </el-button>
      </el-button-group>
    </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      height="100%"
      class="table-container"
      highlight-current-row
    >
      <el-table-column
        fixed
        label="logid"
        width="80"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>

      <el-table-column
        fixed
        label="用户名"
        width="140"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.user }}
        </template>
      </el-table-column>

      <el-table-column
        label="操作模块"
        width="250"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.mode }}
        </template>
      </el-table-column>

      <el-table-column
        label="操作时间"
        width="200"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.dateline }}
        </template>
      </el-table-column>
      <el-table-column
        width="150"
        label="ip"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.ip }}
        </template>
      </el-table-column>

      <el-table-column
        width="350"
        label="操作备注"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.cn }}
        </template>
      </el-table-column>






    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="fetchData"
    />
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import { getadminlog } from '@/api/user'
import { deepClone } from '@/utils'

const _temp = {
  id: '',
  username: '',
  truename: '',
  role: [],
  type: '管理员',
  email: '',
  status: 1
}

export default {
  components: {
    Pagination
  },
  data() {
    return {
      total: 0,
      list: [],
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        created_at: undefined,
        status: undefined,
        keyword: undefined,
        wid:'',
      },
      temp: Object.assign({}, _temp),
      dialogVisible: false,
      dialogType: 'create',
      loading: false
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    search() {
      this.fetchData()
    },
    refresh() {
      this.listQuery = {
        page: 1,
        limit: 20,
        created_at: undefined,
        status: undefined,
        keyword: undefined,
        wid:''
      }
      this.fetchData()
    },
    fetchData() {
      this.listLoading = true
      getadminlog(this.listQuery).then(response => {
        this.list = response.data.data
        this.total = response.data.total
        this.listLoading = false
      })
    }
  }
}
</script>
